package models;

import play.data.validation.Constraints.*;
import play.db.ebean.Model;

import javax.persistence.Entity;
import java.util.List;

import static org.apache.http.impl.auth.BasicScheme.authenticate;


/**
 * Created by inhandui on 12/05/2014.
 */
@Entity
public class Administrador extends Model {

    @Required
    String nome;

    //sera usado como login
    @Required
    @Email
    String email;

    @Required
    String senha;

    @Required
    Long cpf;

    //buscar por email
    public static Finder<String,Administrador> buscar = new Finder(
            String.class, Administrador.class
    );

    //listar todos
    public static List<Administrador> listar(){
        return buscar.all();
    }

    //inserir feito com objeto
    public static void inserir(Administrador administrador){
        administrador.save();
    }

    //excluir pelo email
    public static void excluir(String email){
        buscar.ref(email).delete();
    }
}
